﻿//协议同意按钮
$('.proto i').click(function () {
    if ($(this).hasClass("active")) {
        $(this).removeClass("active");
    } else {
        $(this).addClass("active");
    }
})

$("#sendMessage").click(function () {
    var tel = $("#telphone").val()
    if (tel == "" || !(/^1\d{10}$/.test(tel))) {
        DoAlert('请输入正确的手机号码');
    } else {
        var t;
        var i = 61;
        $("#sendMessage").attr("disabled", "true");
        clearInterval(t);
        t = setInterval(function () {
            i--;
            $('#sendMessage').html(i + 's');
            if (i == 0) {
                $("#sendMessage").removeAttr("disabled");
                $('#sendMessage').html('重新获取');
                clearInterval(t);
                i = 60;
            }
        }, 1000)
        var sval = {
            mobile: tel,
            sendType: 4
        };

        function doCallBack(res) {
            console.log(res);
            // DoAlert(res.message);
            if (res.retcode==0) {
                DoAlert('发送成功');
            }else{
                DoAlert(res.message)
            }
        }
        jAjax("sms.send", doCallBack, sval);
    }

})

function gotoDown()
{
	document.location="down/";
}

$(".submitBtn").click(function() {
	var code = Request["c"];
    var tel = $("#telphone").val();
    var message = $("#message").val();
    if (tel == "" || !(/^1\d{10}$/.test(tel))) {
        DoAlert('请输入正确的手机号码');
    } else if (message == "" || !(/^\d{6}$/.test(message))) {
        DoAlert('请输入正确的验证码');
    } else if (!$('.proto i').hasClass('active')) {
        DoAlert('请勾选同意协议');
    } else {
        var sval = {
           mobile :tel,
           validcode :message,
           code :code
        };

        function doCallBack(res) {
            console.log(res);
			if (res.retcode==0) {
				DoAlert('邀请成功，请下载并安装APP。',gotoDown);
            }else
			{
				DoAlert(res.message);				
			}
        }
        jAjax("account.bindinvitecode", doCallBack, sval);
    }
})

$(document).ready(function () {
	$(".uname").text(Request["n"]);
	$(".ccode").text(Request["c"]);
	
});